import java.util.*;

public class Solution {
    private int len = 0;
    private ArrayList<Integer> list = new ArrayList<>();

    public void Insert(Integer num) {
        len++;
        list.add(num);
    }

    public Double GetMedian() {
        list.sort(
            (o1, o2) -> o1.compareTo(o2));
        if ((len & 1) == 1) {
            return Double.valueOf(list.get(len/2));
        }
        else {
            return Double.valueOf(list.get(len/2 - 1) + list.get(len/2))/2;
        }
    }


}
